#ifndef PARTICLEEFFECT_H_
#define PARTICLEEFFECT_H_

// By: Jesse Guarascia de Urena
// Particle effect class
// Spews particles using the given properties

#include "Sprite.h"
#include "Particle.h"
#include <vector>

class ParticleEffect
{
private:
	int maxParticles; // Maximum particles the effect can have
	float angle; // Base angle the particles use
	float spread; // Spread used for the particles
	float velocity; // Speed of the particles
	int lifeTime; // Life time of the particles

	Sprite sprite; // Sprite used for the particles

	std::vector<Particle> particle; // Particle vector array
	Rect particleRect; // Rectangle all particles have to use
	TryneTimer createTimer; // Timer used to decide whether a new particle should be created

	void CreateParticle(); // Create a new particle

public:
	ParticleEffect(void);
	~ParticleEffect(void);

	// Update the particle effect and it's particles
	void Update();

	// Initialize the particle effect's properties
	void Init(int particles, float _angle, float _spread = 5.0f, float vel = 2.0f, int _lifeTime = 1000);

	// Render the particles
	void Render();

	// Set the rectangle for the particles
	void SetParticleRect(float x, float y, float w, float h);
	void SetParticleRect(Rect rect);

	// Set the sprite the particles will use
	inline void SetSprite(int imageID) { sprite.SetImg(imageID); }

	// Get/Set the properties
	inline int MaxParticles() { return maxParticles; }
	inline void SetMaxParticles(int max) { maxParticles = max; }

	inline float Angle() { return angle; }
	inline void SetAngle(float _angle) { angle = _angle; }

	inline float Spread() { return spread; }
	inline void SetSpread(float _spread) { spread = _spread; }

	inline float Velocity() { return velocity; }
	inline void SetVelocity(float vel) { velocity = vel; }

	inline int LifeTime() { return lifeTime; }
	inline void SetLifeTime(int lfTime) { lifeTime = lfTime; }
};

#endif // PARTICLEEFFECT_H_

